﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

// Created libraries
using FrbaBus.Core;

namespace FrbaBus.Canje_de_Ptos
{
    public partial class CanjePuntos : Form
    {
        public CanjePuntos()
        {
            InitializeComponent();
        }

        private void CanjePuntos_Load(object sender, EventArgs e)
        {
            dataGridView1.ReadOnly = true;
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.AllowUserToDeleteRows = false;
            DBManager db = new DBManager();
            SqlCommand consulta = new SqlCommand("SELECT Nombre, Stock, Valor_Puntos from ALL_IN.Producto order by 3");
            SQLResponse r4 = db.executeQuery(consulta);
            SqlCommand consulta5 = new SqlCommand("select count(*) from ALL_IN.Producto");
            SQLResponse r5 = db.executeQuery(consulta5);
            int valor = (int)r5.result.Rows[0][0];
            for (int i = 0; i < valor; i++)
            {
                dataGridView1.Rows.Add(r4.result.Rows[i][0].ToString(), r4.result.Rows[i][1].ToString(), r4.result.Rows[i][2].ToString());
            }
            db.desconectar();
        }
    }
}
